package cate.common.table.farm.udgpalace.sheet;

import cate.common.table.ESheet;
import cate.common.table.farm.udgpalace.row.UdgPalaceShopRow;
import cate.common.util.random.RWList;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public class UdgPalaceShopSheet extends ESheet<UdgPalaceShopRow> {
    @Override
    public String getSheetName() {
        return "地宫探险商店";
    }

    public List<UdgPalaceShopRow> randomItems(int group, int num) {
        List<UdgPalaceShopRow> list = new ArrayList<>();
        RWList<UdgPalaceShopRow> row = new RWList<>();
        row.addAndSetup(getList().stream().filter(e -> e.group == group).collect(Collectors.toList()));
        for (int i = 0; i < num; ++i) {
            Optional.of(row.get()).ifPresent(list::add);
        }
        return list;
    }
}
